Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

feat: NativeScript bootstrap transformer #634

Merged
merged 4 commits into from
Aug 17, 2018
Merged

feat: NativeScript bootstrap transformer #634

merged 4 commits into from
Aug 17, 2018

Conversation

vakrilov
Copy link
Contributor

@vakrilov vakrilov commented Aug 15, 2018

The bootstrap transformer will automatically replace the platform and bootstrap calls inside main.ts when building with AOT.
This will eliminate the need for main.aot.ts and app.module.ngfactory.d.ts files in templates.

This depends on angular/angular-cli#11786 going public

@@ -3,6 +3,7 @@ const { join, relative, resolve, sep } = require("path");
const webpack = require("webpack");
const nsWebpack = require("nativescript-dev-webpack");
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
const { nsReplaceBootstrap } = require("nativescript-dev-webpack/plugins/ns-replace-bootstrap");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reexport that from the index file?

const entryModule = aot ?
nsWebpack.getAotEntryModule(appFullPath) :
`${nsWebpack.getEntryModule(appFullPath)}.ts`;
const entryModule = `${nsWebpack.getEntryModule(appFullPath)}.ts`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the getAotEntryModule function from index.js as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a breaking change if we remove it completely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. We discussed to introduce a Deprecated decorator in another PR.

const ngCompilerPlugin = new AngularCompilerPlugin({
hostReplacementPaths: nsWebpack.getResolver([platform, "tns"]),
platformTransformers: aot ? [nsReplaceBootstrap(() => ngCompilerPlugin)] : null,
mainPath: resolve(appPath, "main.ts"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, that's from a previous PR (mine ;d), but I think it should be mainPath: entryModule instead of hardcoded to main.ts.

tsconfig.json Outdated
@@ -10,6 +10,7 @@
"files": [
"plugins/PlatformFSPlugin.ts",
"plugins/WatchStateLoggerPlugin.ts",
"plugins/ns-replace-bootstrap.ts",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm, that's not really a webpack plugin. Can we move it to a transformers folder or something like that.

@vakrilov vakrilov changed the title [Do not merge] feat: NativeScript bootstrap transformer feat: NativeScript bootstrap transformer Aug 17, 2018
vakrilov and others added 4 commits August 17, 2018 14:22
The bootstrap transformer will automatically replace the platform and bootstrap calls inside `main.ts` when building with AOT.
This will eliminate the need for `main.aot.ts` and `app.module.ngfactory.d.ts` files in templates.
This won't work for projects that don't have dependency for
`@ngtools/webpack`.
@sis0k0 sis0k0 force-pushed the replace-bootstrap branch from e65d008 to c3a3b0b Compare August 17, 2018 11:26
@sis0k0 sis0k0 merged commit c016418 into master Aug 17, 2018
@sis0k0 sis0k0 deleted the replace-bootstrap branch August 17, 2018 14:01
sis0k0 added a commit that referenced this pull request Aug 28, 2018
It was removed (probably accidentally) in #634.
sis0k0 added a commit that referenced this pull request Aug 31, 2018
It was removed (probably accidentally) in #634.
sis0k0 added a commit that referenced this pull request Sep 10, 2018
<a name="0.16.0"></a>
# [0.16.0](0.15.1...0.16.0) (2018-09-10)
 ### Features
 * NativeScript bootstrap transformer ([#634](#634)) ([c016418](c016418))
manoldonev pushed a commit to NativeScript/nativescript-app-templates that referenced this pull request Jan 9, 2019
They won't be needed with {N}-dev-webpack 0.16.0, because of this change
- NativeScript/nativescript-dev-webpack#634.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants